$(document).ready(function() {



    // FusionCharts.setCurrentRenderer("flash");
 

    });

var systolic = 0,
    diastolic = 0,
    sugar = 0;
	
function bp_num() {
    systolic = Math.floor(Math.random() * (145 - 155 + 1) + 145);
    diastolic = Math.floor(Math.random() * (95 - 105 + 1) + 95);
    $("#systolic-num").html( systolic + "<br/><span>mmHg</span>");
    $("#diastolic-num").html( diastolic + "<br/><span>mmHg</span>");

    var systolic_bulb_ref = FusionCharts("systolic_bulb");	
    systolic_bulb_ref.feedData("&value="+systolic);
    
    var diastolic_bulb_ref = FusionCharts("diastolic_bulb");
    diastolic_bulb_ref.feedData("&value="+diastolic);
}

function sugar_num() {
    $.ajax({
        url: "stt.jsp?M=BATT",
        success: function(data) {
            var sugar_num = data.split("=");
            $("#sugar_num").html(sugar_num[1]+"V");
			
        }
	

    });
}
 

function temp_change() {
     $.ajax({
        url: "stt.jsp?M=TEMPR",
        success: function(data) {
            var temp_num = data.split("=");
            $("#temp_num").html(temp_num[1] +"&deg;C");
			
        }
	

    });
}
 

function pulse_change() {
    $.ajax({
        url: "stt.jsp?M=EP",
        success: function(data) {
            var pulse_num = data.split("=");
			if(pulse_num[1] != ''){
			if(pulse_num[1] =='0.00'){
            $("#pulse_num").html("<0.20V/m");
			$("#pulse_time").html(pulse_num[2]);
			}
			else{$("#pulse_num").html(pulse_num[1]+"V/m");
			$("#pulse_time").html(pulse_num[2]);
			 $("#cichang_num").html(pulse_num[3]+"V/m");
			 $("#oximetry_num").html(pulse_num[6]+"%");
			 $("#temp_num").html(pulse_num[7] +"&deg;C");
			 $("#sugar_num").html(pulse_num[4]+"V/m");
			 $("#gsm1800_num").html(pulse_num[5]+"V/m");
			}
			}
        }
	

    });
}
function cichang_change() {
    $.ajax({
        url: "stt.jsp?M=HP",
        success: function(data) {
            var cichang_num = data.split("=");
			if(cichang_num[1] != ''){
            $("#cichang_num").html(cichang_num[1]+"V/m");
			}
        }
	

    });
}
function oximetry_change() {

    $.ajax({
        url: "stt.jsp?M=RH",
        success: function(data) {
            var oximetry_num = data.split("=");
            $("#oximetry_num").html(oximetry_num[1]  +"%");
        }
    });
}

var xmlRequest = null;   
function initXMLRequest() {   
	if (window.ActiveXObject) {   
	xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");   
	} else {   
	if (window.XMLHttpRequest) {   
	xmlRequest = new XMLHttpRequest();   
	}   
	}   
}
function sendHTTPRequest() {
	initXMLRequest();
	var url = "/ajaxServlet.do";	// 调用的servlet
	if (xmlRequest) {   
	xmlRequest.open("POST", url, true);
	xmlRequest.send(); 
	xmlRequest.onreadystatechange = isDataExists;
	// 使用方法回调，每3秒调用一次
	setTimeout("sendHTTPRequest()",3000);
	}   
}   

setInterval("pulse_change()", 2000);
